home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / CURSOR.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  2KB  |  53 lines

  1. /*****************************************************************/
  2. /**   CURSOR()                                                  **/
  3. /**   ARGUMENTS: A char variable identifiny what to do with     **/
  4. /**              the cursor.                                    **/
  5. /**   RETURN: none                                              **/
  6. /**                                                             **/
  7. /**   DESCRIPTION:  This function receives a character which    **/
  8. /**                 tells it to do one of several things.       **/
  9. /**                 Turn the cursor on or off, or save the      **/
  10. /**                 cursor positon, or restore the position.    **/
  11. /**                                                             **/
  12. /**   BY Bill Wilkie, 1988                                      **/
  13. /*****************************************************************/
  14.  
  15. #include <dos.h>
  16.  
  17. static int position;            /* global to hold cursor postion */
  18.  
  19. void cursor(char tmp)
  20. {
  21.    union REGS inregs,outregs;                   /* cpu registers */
  22.     
  23.    switch(tmp)
  24.    {
  25.       case 'h' :                                  /* CURSOR OFF */
  26.                inregs.h.ah = 1;              /* set cursor size */
  27.                inregs.h.ch = 0x20;  /* set bit turns cursor off */
  28.                int86(0x10,&inregs,&outregs);
  29.                break;
  30.  
  31.       case 's' :                      /* SAVE CURSOR POSITION */
  32.                inregs.h.ah = 3; /* read cursor positon and size */
  33.                inregs.h.bh = 0;              /* from page zero */
  34.                int86(0x10,&inregs,&outregs);
  35.                position = outregs.x.dx;       /* store positon */
  36.                break;
  37.  
  38.       case 'r' :                     /* RESTORE CURSOR POSITON */
  39.                inregs.h.ah = 2;         /* set cursor positon */
  40.                inregs.h.bh = 0;              /* on page zero */
  41.                inregs.x.dx = position; /* at this old position */
  42.                int86(0x10,&inregs,&outregs);
  43.                break;
  44.  
  45.       case 'o' :                                   /* CURSOR ON */
  46.                inregs.h.ah = 1;     /* set cursor size */     
  47.                inregs.h.ch = 6;     /* cursor start line */
  48.                inregs.h.cl = 7;     /* cursor end line */
  49.                int86(0x10,&inregs,&outregs);
  50.                break;
  51.     }
  52. }
  53.